update ad_user set password='888';

delete from m_storage;

insert into m_storage (
  M_PRODUCT_ID, M_LOCATOR_ID, AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, CREATED, CREATEDBY, UPDATED, UPDATEDBY,
  QTYONHAND, QTYRESERVED, QTYORDERED, DATELASTINVENTORY, M_ATTRIBUTESETINSTANCE_ID, M_STORAGE_ID,
  ISALLOWPICKING, ADJUSTNUM, FREEZESTORAGENUM)
select pid,lid,cid,org_id,'Y',sysdate,cby,sysdate,uby,
  cnt,0,0,null,0,m_storage_seq.nextval,'N',0,0
from (
  select p.m_product_id pid,l.m_locator_id lid,max(i.ad_client_id) cid,max(i.AD_ORG_ID) org_id,
    max(i.CREATEDBY) cby,max(i.UPDATEDBY) uby, count(1) cnt
  from wt_iteminfo i
    left join m_product p on i.m_product_id=p.m_product_id
    left join m_locator l on i.m_locator_id=l.m_locator_id
  where i.status='FSC' AND l.M_LOCATOR_ID IS NOT null
  group by p.m_product_id,l.m_locator_id
);

DECLARE
cursor c_seq is
select SEQUENCE_NAME||','||last_number from user_sequences
order by SEQUENCE_NAME;
p_sequenceName varchar2(50);
p_sequenceName1 varchar2(50);
p_current_seq_value  varchar2(50);
p_seqNextValue varchar2(50);
p_diff_value number;
a varchar2(10);
BEGIN
  open c_seq;
 LOOP
    fetch c_seq into p_sequenceName;
    exit when c_seq%notfound;
    p_sequenceName1:=SUBSTR(p_sequenceName,0,INSTR(p_sequenceName,',')-1);
    p_current_seq_value:=SUBSTR(p_sequenceName,INSTR(p_sequenceName,',')+1);
    p_seqNextValue:=to_number(SUBSTR(p_sequenceName,INSTR(p_sequenceName,',')+1))+1000000;
    p_diff_value:=to_number(p_seqNextValue)-to_number(p_current_seq_value);
       execute immediate'alter sequence '|| p_sequenceName1|| ' increment by '|| abs(p_diff_value)  ||' nocache';
       execute immediate 'select '||p_sequenceName1||'.nextval from dual' into a;
       execute immediate 'alter sequence '|| p_sequenceName1|| ' increment by 1 cache 20';
  END LOOP;
   exception when others then
    dbms_output.put_line('sqlerrm='||SQLERRM);
END;

/

exit